package com.jingzhe.controller.sys;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jingzhe.biz.sys.domain.SysOffice;
import com.jingzhe.biz.sys.service.ISysOfficeService;

/**
 * 机构管理
 * @author wanghj
 *
 */
@Controller
@RequestMapping("/sys/office")
public class OfficeWeb {
    private final static Logger  logger = LoggerFactory.getLogger(OfficeWeb.class);
    
    @Resource
    private ISysOfficeService sysOfficeService;
    
    /**
     * 机构管理页
     */
    private final static String OFFICE_MANAGE_PAGE = "sys/office/officeManage";
    
    /**
     * 跳转到机构管理页
     * @return
     */
    @RequestMapping(value = "", method = RequestMethod.GET)
    public String toOffice(HttpServletRequest request) {
        return OFFICE_MANAGE_PAGE;
    }
    
    /**
     * 根据上级机构，获取下级机构列表
     * @param parentId
     * @return
     */
    @RequestMapping(value = "/select-by-parent-id", method = RequestMethod.GET)
    @ResponseBody
    public List<SysOffice> selectByParentId(@RequestParam Integer parentId) {
        return sysOfficeService.selectByParentId(parentId);
    }
}
